﻿
namespace SRTSolutions.Elevate.Guide
{
    using global::System;
    using global::System.Threading;
    using global::NUnit.Framework;

    public class TimingThings
    {
        [Test]
        public void TimingActions()
        {
            //given an action
            Action action = () => Thread.Sleep(1002);

            //we can get the wall time that it took to run
            //it like this
            TimeSpan result = action.Time();
            Assert.That(result.TotalSeconds, Is.EqualTo(1.25).Within(.3));
        }

        #region Unit Tests

        [Test]
        public void TimingWithNullAction()
        {
            Assert.Throws<ArgumentNullException>(() => Timing.Time(null));
        }

        #endregion
    }
}
